package collection;

import java.util.*;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(1,3));
        list.add(new Point(10,83));
        list.add(new Point(71,53));
        list.add(new Point(21,13));
        list.add(new Point(51,34));
        list.add(new Point(11,3));
        System.out.println("list原始数据:"+list);


        /*list.sort((o1, o2) -> o1.getX()-o2.getX());
        System.out.println(list);
*/
        list.sort((o1, o2) -> {
            int a = o1.getX() + o1.getY();
            int b = o2.getX() + o2.getY();
            return a - b;
        });
        System.out.println("list排序数据:"+list);
    }
}
